import java.util.Scanner;

/**
 * Creat by TanLei
 * Description:
 * User:86183
 * Date:2022-05-11
 * Time:21:08
 */
public class Demo16 {

//  private volatile static int isQuit = 0;

    private static int isQuit = 0;

    public static void main(String[] args) {
        Thread thread = new Thread(() -> {

            while (true) {
                synchronized (Demo16.class) {
                    if (isQuit != 0) {
                        break;
                    }
                }

            }
            System.out.println("thread 线程结束");
        });
        thread.start();

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个整数：");
        isQuit = scanner.nextInt();
        System.out.println("main线程结束");
    }
}
